package study.jdk.spi.logger;

import java.util.Iterator;
import java.util.ServiceLoader;

public class LoggerFactory {

    public LoggerFactory() {
    }

    public static Logger getLogger() {
        ServiceLoader<Logger> loader = ServiceLoader.load(Logger.class);
        Iterator<Logger> it = loader.iterator();
        Logger logger = null;
        if (it.hasNext()) {
            logger = it.next();
        }
        if (loader == null) {
            throw new IllegalStateException("未发现");
        }
        return logger;
    }
}
